/*
 * Subject.java
 *
 * Created on 31 de Julho de 2007, 22:57
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package padroes;

import InterfacePersistencia.conexao.*;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;

/**
 *
 * @author Mateus
 */
public class NewMimeMessageObservable extends DeletedMessagesObservable{
    
    List<NewMimeMessageObserver> observers = new ArrayList<NewMimeMessageObserver>();
    /** Creates a new instance of Subject */
    public NewMimeMessageObservable() {
    }
    
    public void addMimeObservers(NewMimeMessageObserver o){
        observers.add(o);
    }
    
    public void removeObservers(NewMimeMessageObserver o){
        observers.remove(o);
    }
    
    public void notifyObservers(MimeMessage mimeMessage) throws MessagingException, IOException{
       Iterator it = observers.iterator();
          
       while(it.hasNext()){
           NewMimeMessageObserver o = (NewMimeMessageObserver) it.next();
           o.update(mimeMessage, this);
       }
    }
    
}

